import 'dart:convert';

import 'package:json_annotation/json_annotation.dart';

part 'simple_user_info.g.dart';

@JsonSerializable(includeIfNull: false, explicitToJson: true)
class SimpleUserInfo {
  @JsonKey(name: 'sysUserData', nullable: true)
  SystemUser systemUser;

  List<String> permissions;

  SimpleUserInfo({this.systemUser, this.permissions});

  factory SimpleUserInfo.fromJson(Map<String, dynamic> json) => _$SimpleUserInfoFromJson(json);

  Map<String, dynamic> toJson() => _$SimpleUserInfoToJson(this);
}

@JsonSerializable()
class SystemUser {
  int userId;
  int deptId;
  String deptName;
  String userName;
  @JsonKey(name: 'nickName')
  String nickname;
  String email;
  @JsonKey(name: 'phonenumber')
  String phoneNumber;
  String sex;
  String avatar;

  SystemUser(
      {this.userId,
      this.deptId,
      this.deptName,
      this.userName,
      this.nickname,
      this.email,
      this.phoneNumber,
      this.sex,
      this.avatar});

  factory SystemUser.fromJson(Map<String, dynamic> json) => _$SystemUserFromJson(json);

  Map<String, dynamic> toJson() => _$SystemUserToJson(this);

  String toJsonString() => json.encode(toJson());

  factory SystemUser.fromJsonString(String jsonString) => SystemUser.fromJson(json.decode(jsonString));
}
